$(document).ready(function(){

    // first day of next month
    var date = new Date('07/01/2008');
    var month = date.toString().split(' ')[1];

    // http://docs.jquery.com/Manipulation/appendTo#content
    var cal = $('<div/>').appendTo($('body'));

    // start on a sunday and write six weeks
    date.setDate(date.getDate()-date.getDay());
    for( var i=0; i<42; i++ ) {
        $('<div/>').html(date.getDate())
                .data('date',new Date(date))
                .addClass(date.toString().split(' ')[0])
                .addClass(date.toString().split(' ')[1])
                .appendTo(cal);
        date.setDate(date.getDate()+1);
    }

    // arrange blocks
    $('div',cal).css('float','left')
            .filter('.Sun').css('clear','left');

    // borders
    $('div',cal).css({ width: '25px', height: '25px', border: '1px solid red' });

    // style days outside month
    $('div',cal).not( '.'+month ).css('color','lightgray');

    // TODO: add click handler...
    $('div',cal).bind('click',function(){
        console.log($(this).data('date'));
    });
});